#!/bin/bash

gpio_group=(499 498 496 497 437 420 433 432 430 436 323)
sleepTime=0.1
# Define a function to toggle the pins
toggle_pins()
{
    for((i=0;i<${#gpio_group[*]};i++))
    do
#	    echo ${gpio_group[i]}
            ./gpio set ${gpio_group[i]}
            sleep $sleepTime
    done

    for((i=0;i<${#gpio_group[*]};i++))
    do
            ./gpio clear ${gpio_group[i]}
            sleep $sleepTime
    done
}

# Call the toggle_pins function
data_a7=$(cat /sys/bus/iio/devices/iio\:device0/in_voltage7_raw)
echo "mikbus status(L):" $data_a7
[ $data_a7 -ge 200 ] && { echo "mikbus low status failed"; exit 1; }
toggle_pins
data_a7=$(cat /sys/bus/iio/devices/iio\:device0/in_voltage7_raw)
echo "mikbus status(H):" $data_a7
[ $data_a7 -le 3000 ] && { echo  "mikbus high status failed"; exit 2; }
echo "Mikbus Test OK"
./gpio clear 481
